home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.19970929-19971216 / 000085_news@newsmaster….columbia.edu _Mon Oct 13 13:42:19 1997.msg < prev    next >
Internet Message Format  |  2020-01-01  |  4KB

  1. Return-Path: <news@newsmaster.cc.columbia.edu>
  2. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.35.30])
  3.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id NAA28824
  4.     for <kermit.misc@watsun.cc.columbia.edu>; Mon, 13 Oct 1997 13:42:18 -0400 (EDT)
  5. Received: (from news@localhost)
  6.     by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id NAA00594
  7.     for kermit.misc@watsun; Mon, 13 Oct 1997 13:42:18 -0400 (EDT)
  8. Path: news.columbia.edu!watsun.cc.columbia.edu!fdc
  9. From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  10. Newsgroups: comp.protocols.kermit.misc
  11. Subject: Re: Need script to run automatically after each K95 server-mode file received...
  12. Date: 13 Oct 1997 17:42:13 GMT
  13. Organization: Columbia University
  14. Lines: 68
  15. Message-ID: <61tmhl$j3a$1@apakabar.cc.columbia.edu>
  16. References: <344255EA.40ACF522@southeast.net>
  17. NNTP-Posting-Host: watsun.cc.columbia.edu
  18. Xref: news.columbia.edu comp.protocols.kermit.misc:7861
  19.  
  20. In article <344255EA.40ACF522@southeast.net>,
  21. newguy  <newguy@southeast.net> wrote:
  22. : We run Kermit95 in server-mode to receive files from a database machine
  23. : unattended.
  24. : Unfortunately, we need the file names on the received end to be renamed
  25. : from the name that the sending kermit is using.  The _real_ name that
  26. : should be used is contained in a text line in the file itself (i.e.
  27. : something like FILENAME=what.name.should.really.be .
  28. : Is there a way to get a script to run after each successful receipt of a
  29. : file while remaining in server mode?  (A simple script could read the
  30. : file, get the proper name, and then rename the file.)
  31. No.  As long as Kermit stays in server mode, it won't run any scripts, and
  32. presently we have no provision for "user exits" upon receipt of files, though
  33. this might be added in the future.
  34.  
  35. : Failing that, could anyone help with a script that would:
  36. :     1) manually wait to receive a file (forever)
  37. :     2) after successful receipt, rename the file
  38. :     3) loop back to step 1
  39. : (In effect, this script would act like server mode)
  40. Something like this:
  41.  
  42. while true {
  43.     receive
  44.     if fail continue
  45.     "rename the file"
  46. }          
  47.  
  48. The question is, how does "rename the file" work?  This is left as an
  49. exercise to the reader :-) Here are some hints:
  50.  
  51.  . You can use OPEN READ, READ, and CLOSE read to read lines from
  52.    a file.  Use this to read the "FILENAME=what.name.should.really.be"
  53.    files.  To avoid having to do this every time a new file arrives,
  54.    read them into an array, then loop through the array to accomplish
  55.    the lookup each time.
  56.  
  57.  . Or for the more adventurous, read the file once and create an associative
  58.    list in which the variable name is constructed from the left hand side of
  59.    the =, and its value is the right hand side.  (Subhint: See page 457 of
  60.    "Using C-Kermit", 2nd Ed, for how to construct variable names
  61.    dynamically).
  62.  
  63.  . Parse the lines from this file using the following functions (examples
  64.    assume that \%a holds a line from the file-naming file):
  65.  
  66.      \fstripx(string[,character])
  67.     This function removes the rightmost segment of the string that 
  68.     starts with the given character.  Example:
  69.  
  70.       assign original_name \fstripx(\%a,=)
  71.  
  72.      \flop(string[,char])
  73.     Removes the leftmost segment of the string that ends with the 
  74.     given character.  If no character is given, period (.) is used.
  75.         Example:
  76.  
  77.       assign new_name \flop(\%a,=)
  78.  
  79. So:
  80.  
  81.   rename \fstripx(\%a,=) \flop(\%a,=)
  82.  
  83. - Frank